﻿using BlogApi.Models;
using BlogApi.ModelsDto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BlogApi.Services
{
    /// <summary>
    /// 文章仓储接口
    /// </summary>
    public interface IArticleRepository
    {
        /// <summary>
        /// 获取所有文章数据
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<Article>> GetArticlesAsync();
        /// <summary>
        /// 获取按时间降序分页后文章数据
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        Task<IEnumerable<Article>> GetArticlesByPageAsync(int pageSize,int pageIndex);
        /// <summary>
        /// 搜索标题包含关键字的文章
        /// </summary>
        /// <param name="keyword"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        Task<IEnumerable<ArticleAndUserInfoDto>> SearchPublishedArticleByPage(string keyword, int pageSize, int pageIndex);
        /// <summary>
        /// 获取单个文章数据
        /// </summary>
        /// <param name="articleId"></param>
        /// <returns></returns>
        Task<Article> GetArticleAsync(Guid articleId);
        /// <summary>
        /// 获取某个用户的文章数据
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        Task<IEnumerable<Article>> GetUserArticlesByPageAsync(Guid userId, int pageSize, int pageIndex);
        /// <summary>
        /// 获取按时间降序分页后的文章数据和对应文章的作者信息
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        Task<IEnumerable<ArticleAndUserInfoDto>> GetArticleAndUserInfosByPageAsync(int pageSize, int pageIndex);
        /// <summary>
        /// 根据文章ID获取一个文章和用户信息的Dto
        /// </summary>
        /// <param name="articleId"></param>
        /// <returns></returns>
        Task<ArticleAndUserInfoDto> GetArticleAndUserInfoDtoByArticleIdAsync(Guid articleId);
        /// <summary>
        /// 获取按浏览量降序分页后的文章数据和对应文章的作者信息
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        Task<IEnumerable<ArticleAndUserInfoDto>> GetArticleAndUserInfosByPageOrderByBrowseNumber(int pageSize, int pageIndex);
        /// <summary>
        /// 新增文章
        /// </summary>
        /// <param name="article">新增的文章模型实体</param>
        void AddArticle(Article article);
        /// <summary>
        /// 更新文章
        /// </summary>
        /// <param name="article"></param>
        void UpdateArticle(Article article);
        /// <summary>
        /// 删除某篇文章
        /// </summary>
        /// <param name="article"></param>
        void DeleteArticle(Article article);
        /// <summary>
        /// 判断文章是否存在
        /// </summary>
        /// <param name="articleId"></param>
        /// <returns></returns>
        Task<bool> ArticleExistsAsync(Guid articleId);
        /// <summary>
        /// 保存更新
        /// </summary>
        /// <returns></returns>
        Task<bool> SaveAsync();
        /// <summary>
        /// 用户空间的文章列表
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        Task<IEnumerable<Article>> GetUserSpaceArticleByPageAsync(Guid userId, int pageSize, int pageIndex);
    }
}
